package com.demo0301.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//1.创建一个类 继承 HttpServlet
//2.重写方法 doGet doPost
//3.添加注解 配置映射URL
@WebServlet("/demo0301/demo02.do")
public class Demo02Servlet extends HttpServlet {
    /**
     * @param request  由Tomcat封装 将浏览器发送来的所有请求数据 都封装在该对象中。以获取（get）为主
     * @param response 由Tomcat封装 将服务器即将发送给浏览器的响应数据 封装在该对象中。以设置为主
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //不管是 get 还是 post 请求方式，都调用同一段逻辑
        doGet(req, resp);
    }
}
